function validateAndShow(type) {

	var projectName = document.getElementById("projectName").value;
	var projectDescription = document.getElementById("projectDescription").value;
	var searchText = document.getElementById("searchName").value;
	if (projectName.length == 0) {

		document.getElementById('errorMsg').innerHTML = "<h4><span style='color:red'>Please fill Projectname</span></h4>";
		return;
	}

	if (projectDescription.length == 0) {

		document.getElementById('errorMsg').innerHTML = "<h4><span style='color:red'>Please fill ProjectDescription</span></h4>";
		return;
	}

	if (searchText.length == 0) {

		document.getElementById('errorMsg').innerHTML = "<h4><span style='color:red'>Please enter name to search</span></h4>";
		return;
	}

	else {
		$.ajax({
			url : 'submitSearch',
			type : "GET",
			contentType : "application/json",
			data : ({
				searchText : searchText,
				type : type
			}),
			success : function(data) {
				$('#showUsers').html(data);

			}
		});
	}

}

function addUser(index, type) {

	$.ajax({
		url : 'selectUser',
		type : "POST",
		data : ({
			index : index,
			type : type
		}),
		success : function(data) {
			$('#showUsers').html(data);

		}
	});

	selectedUsers(type);

}

function selectedUsers(type) {

	$.ajax({
		url : 'selectedUser',
		data : ({
			type : type
		}),
		success : function(data) {
			$('#selectedUsers').html(data);

		}
	});
}
function deleteUser(index, type) {

	$.ajax({
		url : 'deleteUser',
		type : "POST",
		data : ({
			index : index,
			type : type
		}),
		success : function(data) {
			$('#selectedUsers').html(data);

		}
	});

}

function deleteProject(projectName) {

	$.ajax({
		url : 'deleteProject',
		type : "POST",
		data : ({
			index : index
		}),
		success : function(data) {
			$('#statusMsg').html(data);

		}
	});

}

function displaySelectedUsers(projectDescription) {

	document.getElementById("projectDescription").value = projectDescription;
	$.ajax({
		url : 'showSelectedUsers',
		type : "GET",
		success : function(data) {
			$('#selectedUsers').html(data);

		}
	});
}

function validate() {

	var projectName = document.getElementById("projectName").value;
	var projectDescription = document.getElementById("projectDescription").value;
	if (projectDescription.length == 0 || projectName.length == 0) {
		document.getElementById('errorMsg').innerHTML = "<h4><span style='color:red'>Please fill mandatory fields</span></h4>";

		return false;
	}
}

function selecttheProjectByName(projectName) {
	$.ajax({
		url : 'updateProjectDetails',
		type : "GET",
		data : ({
			projectName : projectName
		}),
		success : function(data) {
			$('#showResult').html("");
			$('#showResult').html(data);

		}
	});

}